// ignore_for_file: prefer_const_constructors, avoid_print

import 'package:flutter/material.dart';
import 'package:junyeyishu/ui/mine/widget/QGSendCodeWidget.dart';
import 'package:junyeyishu/ui/mine/widget/QGSendCodeWidget1.dart';

import 'package:junyeyishu/utils/utils.dart';
import 'package:junyeyishu/widgets/QGCircleCheckWidget.dart';
import 'package:junyeyishu/widgets/QGWidget.dart';

class QGMineLogoffPage extends StatefulWidget {
  const QGMineLogoffPage({super.key});

  @override
  State<QGMineLogoffPage> createState() => _QGMineLogoffPageState();
}

class _QGMineLogoffPageState extends State<QGMineLogoffPage> {
  bool check = false;

  @override
  Widget build(BuildContext context) {
    return QGScaffold(
        title: '注销账户',
        bgColor: Color(0XFF0c1012),
        body: Stack(
          children: [
            Container(
                padding: EdgeInsets.only(left: 20.rpx, right: 20.rpx),
                child: Column(children: [
                  SizedBox(height: 25.rpx),
                
                  Row(mainAxisAlignment: MainAxisAlignment.start, children: [
      Expanded(
          child: Text(
        '账号注销后无法恢复，请谨慎操作，注销前请检查以下事项',
        style: TextStyle(
            fontSize: 12.rpx,
            fontWeight: FontWeight.normal,
            color: Color(0xFF989EA4)),
      ))
    ]),
                  SizedBox(height: 20.rpx),
                  buildContent('1. 注销帐号前，请先关闭钱包自动续费功能，并将钱包账户的余额全部提现。', 14),
                  SizedBox(height: 30.rpx),
                  buildContent('2. 您的账号中如果有末售出的藏品，无法注销。', 14),
                  SizedBox(height: 30.rpx),
                  buildContent(
                      '3. 账号注销后，账户下的订单记录无法找回，昵称、头像、钱包地址等个人信息均会被删除。', 14),
                  SizedBox(height: 30.rpx),
                  buildContent('4. 注销后，该账号将无法登录。', 14),
                  SizedBox(height: 30.rpx),
                  buildContent('5. 注销后，该手机号30天内无法注册新用户。', 14),
                ])),
            Positioned(left: 0, bottom: 44.rpx, child: buildBottom())
          ],
        ));
  }

  buildContent(String content, int fontsize) {
    return Row(mainAxisAlignment: MainAxisAlignment.start, children: [
      Expanded(
          child: Text(
        content,
        style: TextStyle(
            fontSize: fontsize.rpx,
            fontWeight: FontWeight.normal,
            color: Color(0xFFffffff)),
      ))
    ]);
  }

  buildBottom() {
    return Container(
        width: kScreenWidth,
        padding: EdgeInsets.only(left: 15.rpx, right: 15.rpx),
        child: Column(
          children: [buildAgree(), SizedBox(height: 20.rpx), buildButton()],
        ));
  }

  buildAgree() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        QGCircleCheckWidget(
          size: 12.rpx,
          select: check,
          image: 'login_check',
          onTap: (checkbox) {
            check = checkbox;
            setState(() {});
          },
        ),
        // SizedBox(
        //   width: 10.rpx,
        // ),
        Text(
          '我已阅读并知晓，愿意承担注销账户带来的后果',
          style: TextStyle(
              fontSize: 12.rpx,
              fontWeight: FontWeight.normal,
              color: Color(0xFFffffff)),
        )
      ],
    );
  }

  buildButton() {
    return Row(
      children: [
        Expanded(
            child: Container(
          height: 44.rpx,
          decoration: check
              ? BoxDecoration(
                  gradient: const LinearGradient(
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                    colors: [Color(0xFF4AE3FF), Color(0xFF44FFF0)],
                  ),
                  borderRadius: BorderRadius.circular(10.rpx),
                )
              : BoxDecoration(
                  gradient: LinearGradient(
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                    colors: [
                      const Color(0xFF4AE3FF).withOpacity(0.4),
                      const Color(0xFF44FFF0).withOpacity(0.4)
                    ],
                  ),
                  borderRadius: BorderRadius.circular(10.rpx),
                ),
          child: TextButton(
              onPressed: () {
                if (check) {
                  showModalBottomSheet(
                      shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(20.rpx)),
                      context: context,
                      backgroundColor: Color(0xFF232A32),
                      builder: (BuildContext context) {
                        return SingleChildScrollView(
                          child: Container(
                              padding: EdgeInsets.only(
                                  bottom:
                                      MediaQuery.of(context).viewInsets.bottom),
                              child:
                                  QGSendCodeDialog(url: url_u_cancelAccount)),
                        );
                      });
                }
              },
              child: Text(
                '确认注销',
                style: TextStyle(
                    fontSize: 14.rpx,
                    fontWeight: FontWeight.bold,
                    color: check ? Color(0xFF111111) : Color(0xFF999999)),
              )),
        ))
      ],
    );
  }
}
